#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    _login_dlg = new LoginDialog(this);
    setCentralWidget(_login_dlg);
//    创建和注册消息连接
    connect(_login_dlg, &LoginDialog::SigSwitchReg, this, &MainWindow::SlotSwitchReg);
    _reg_dlg = new RegisterDialog(this);
    // 指定了父窗口，那么子组件默认会显示出来，故需要手动 hide
    _reg_dlg->hide();

//    移除掉边框和右上角的最大化、最小化按钮
    _login_dlg->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
    _reg_dlg->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::SlotSwitchReg()
{
    setCentralWidget(_reg_dlg);
    _reg_dlg->show();
    _login_dlg->hide();
}
